package com.yhsoft.bill.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yhsoft.bill.controller.request.SalerCzInVo;
import com.yhsoft.bill.controller.request.SalerCzMxInVo;
import com.yhsoft.bill.controller.response.SalerCwtjOutVo;
import com.yhsoft.bill.controller.response.SalerCzMxOutVo;
import com.yhsoft.bill.controller.response.SalerXhLogOutVo;
import com.yhsoft.bill.controller.response.SalerYfzkOutVo;
import com.yhsoft.bill.service.ISalerYfmxService;
import com.yhsoft.bill.service.ISysYszkService;
import com.yhsoft.buyer.service.IBuyerOrderService;
import com.yhsoft.common.response.PageResult;
import com.yhsoft.common.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 渠道商充值明细表 前端控制器
 * </p>
 *
 * @author yyyyyyyh
 * @since 2023-11-03
 */
@Api(tags = {"H-财务统计-渠道商应付账款"})
@RestController
@RequestMapping("/bill/salerYf")
public class SalerYfmxController {
    @Resource
    private ISysYszkService iSysYszkService;

    @Resource
    private ISalerYfmxService iSalerYfmxService;

    @Resource
    private IBuyerOrderService iBuyerOrderService;

    @ApiOperation("财务统计")
    @GetMapping("/getCwtj")
    public Result<SalerCwtjOutVo> getCwtj() {
        SalerCwtjOutVo cwtjOutVo = iBuyerOrderService.getSalerCwtj();
        return Result.success(cwtjOutVo);
    }

    @ApiOperation("应付账款")
    @GetMapping("/getYf")
    public Result<SalerYfzkOutVo> getYf() {
        SalerYfzkOutVo yszk = iSysYszkService.getSalerYf();
        return Result.success(yszk);
    }

    @ApiOperation("充值")
    @PostMapping("/cz")
    public Result<?> cz(@RequestBody SalerCzInVo inVo) {
        String result = iSalerYfmxService.cz(inVo);
        if (result.equals("success")) {
            return Result.success(result);
        }
        return Result.fail(result);
    }

    @ApiOperation("充值明细")
    @GetMapping("/getCzMx")
    public Result<PageResult<SalerCzMxOutVo>> getCzMx(SalerCzMxInVo inVo,
                                                      @RequestParam(value = "pageNo") Long pageNo,
                                                      @RequestParam(value = "pageSize") Long pageSize) {
        IPage<SalerCzMxOutVo> iPage = iSalerYfmxService.getCzMx(inVo, pageNo, pageSize);
        return Result.success(PageResult.valueOf(iPage));
    }

    @ApiOperation("消耗日志")
    @GetMapping("/getXhLog")
    public Result<PageResult<SalerXhLogOutVo>> getXhLog(SalerCzMxInVo inVo,
                                                        @RequestParam(value = "pageNo") Long pageNo,
                                                        @RequestParam(value = "pageSize") Long pageSize) {
        IPage<SalerXhLogOutVo> iPage = iSalerYfmxService.getXhLog(inVo, pageNo, pageSize);
        return Result.success(PageResult.valueOf(iPage));
    }

}
